package com.Web.Session;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "SessionServletdemo2", value = "/SessionServletdemo2")
public class SessionServletdemo2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1.通过rquest对象，获取session对象
         HttpSession session = request.getSession();
         // 2.操作session的API，存储数据
        session.setAttribute("username", "哈哈，呵呵");
    }
}
